﻿namespace HEFramework
{
    public static class AudioComponentSystem
    {
        [EntitySystem]
        public class AudioComponentAwakeSystem : AwakeSystem<AudioComponent, int>
        {
            protected override void Awake(AudioComponent _self, int _type)
            {
                switch (_type)
                {
                    case 0:
                        _self.AudioSource = AudioSourcePlayer.Instance.AddBGMAudioSource<BGMAudioSource>();
                        break;
                    case 1:
                        _self.AudioSource = AudioSourcePlayer.Instance.AddEffect2DAudioSource<Effect2DAudioSource>();
                        break;
                    case 2:
                        _self.AudioSource = AudioSourcePlayer.Instance.AddEffect3DAudioSource<Effect3DAudioSource>();
                        break;
                }
            }
        }


        [EntitySystem]
        public class AudioComponentDestroySystem : DestroySystem<AudioComponent>
        {
            protected override void Destroy(AudioComponent _self)
            {
                _self.AudioSource.Recycle();
            }
        }
    }
}